# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=gleam
pkgver=0.22.1
pkgrel=0
pkgdesc="Statically-typed language that compiles to Erlang and JS"
url="https://gleam.run/"
# limited by s390x, riscv64: rust; ppc64le: ring
arch="all !s390x !riscv64 !ppc64le"
license="Apache-2.0"
depends="erlang-dev"
makedepends="cargo openssl-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/gleam-lang/gleam/archive/refs/tags/v$pkgver.tar.gz"

# system libs
export CARGO_FEATURE_USE_SYSTEM_LIBS=1
export OPENSSL_NO_VENDOR=1

# optimise size
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dvm755 target/release/gleam -t "$pkgdir"/usr/bin/
}

sha512sums="
ef1477aca23bb45e6b308578c79930d9d591574a76f23b25f96b5bc6185a2dbe2229ffda73ede19545d130802073bec44de35c6e941b89a81eb3b08bf93dcc03  gleam-0.22.1.tar.gz
"
